package com.yonyou.cyxdms.basedata.service.controller.vehicleproduct;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyxdms.basedata.client.domains.vo.VsMasterInfoVO;
import com.yonyou.cyxdms.basedata.service.dto.vehiclemaster.VehicleMasterInfoDTO;
import com.yonyou.cyxdms.basedata.service.service.product.VsProductService;
import com.yonyou.cyxdms.basedata.service.vo.productinfo.VsProductVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * dcs车辆主数据
 *
 * @author renwd
 * @since 2019/7/19
 */

@Api(value = "VehicleMasterInfoController", tags = "dcs车辆主数据")
@RestController
@RequestMapping("/vehicleMasterInfo")
public class VehicleMasterInfoController {

    @Autowired
    private VsProductService vsProductService;

    /**
     * dcs车辆主数据
     *
     * @param pageNum
     * @param pageSize
     * @param queryParam
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yonyou.cyxdms.basedata.service.vo.productinfo.VsProductVO>
     * @author renwd
     * @since 2019/7/19
     */
    @ApiOperation(value = "dcs车辆主数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping
    public IPage<VsProductVO> queryProductInfo(@RequestParam("pageNum") Long pageNum, @RequestParam("limit") Long pageSize, @RequestParam Map<String, Object> queryParam) {
        Page<VsProductVO> page = new Page<>(pageNum, pageSize);
        return vsProductService.queryVehicleMasterInfo(page, queryParam);
    }

    /**
     * 根据id查询车辆主数据
     *
     * @param id
     * @return com.yonyou.cyxdms.basedata.service.vo.productinfo.VsMasterInfoVO
     * @author renwd
     * @since 2019/7/24
     */
    @ApiOperation(value = "根据id查询车辆主数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/{id}")
    public VsMasterInfoVO queryProductInfoById(@PathVariable("id") Long id) {
        return vsProductService.queryProductInfoById(id);
    }

    /**
     * TCC获取车辆主数据
     *
     * @author ysj
     * @date 2019/11/19
     * @param id
     * @return
     */
    @ApiOperation(value = "TCC根据id查询车辆主数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/queryTccProductInfoById/{id}")
    public VsMasterInfoVO queryTccProductInfoById(@PathVariable("id") Long id) {
        return vsProductService.queryTccProductInfoById(id);
    }

    /**
     * 根据id修改车辆主数据
     *
     * @param id
     * @param vehicleMasterInfoDTO
     * @return void
     * @author renwd
     * @since 2019/7/24
     */
    @ApiOperation(value = "根据id修改车辆主数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @PutMapping("/{id}")
    public void modifyProductInfo(@PathVariable("id") Long id, @RequestBody VehicleMasterInfoDTO vehicleMasterInfoDTO) {
        vsProductService.modifyProductInfo(id, vehicleMasterInfoDTO);
    }

}
